<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>AssignExpert</title>
<script type="text/javascript" src="../script/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var planId = '<s:property value="planId" />';
        $("#selectExpert").hide();
        $.getJSON("../expert/GetExpertUnit.action",
            function(data) {
                var unitArr = new Array();
                for (var i = 0; i < data.expertUnitList.length; i++) {
                    unitArr.push('<option value="' + data.expertUnitList[i] + '">' + data.expertUnitList[i] + '</option>');
                }
                $("#expertUnit").append(unitArr.join(''));
                $("#expertUnit").change(function() {
                    if ($(this).val() != "0" && $(this).val() != null) {
                        $.getJSON("../expert/GetExpertList.action", {"unitName": escape($(this).val())},
                            function(data) {
                                var expertNameArr = new Array();
                                for (var j = 0; j < data.expertList.length; j++) {
                                    expertNameArr.push('<option value="' + data.expertList[j].expertid + '">' + data.expertList[j].expertname + '</option>');
                                }
                                $("#expertName").append(expertNameArr.join(''));
                            }
                        );
                    }
                });
            }
        );
        var selectText;
        var selectHidden;
        $(".select-expert-button").click(function() {
            selectText = $(this).siblings(".select-expert-text");
            selectHidden = $(this).siblings(".select-expert-hidden");
            $("#selectExpert").show();
            $("#ADD_BUTTON").click(function() {
            	var expertName = $("#expertName option:selected").text();
            	var expertId = $("#expertName option:selected").val();
                if (expertId != "0") {
                    selectText.val(expertName);
                    selectHidden.val(expertId);
                    $("#selectExpert").hide();
                }
            });
            $("#CANCEL_BUTTON").click(function() {
                $("#selectExpert").hide();
            });
        });
        $("#ASSIGN_BUTTON").click(function() {
            $.getJSON("AssignExpert.action", 
                {
                    "prjExperts.prjPkid": planId,
                    "prjExperts.groupleader": $(".select-expert-hidden").get(0).value,
                    "prjExperts.expert1": $(".select-expert-hidden").get(1).value,
                    "prjExperts.expert2": $(".select-expert-hidden").get(2).value,
                    "prjExperts.expert3": $(".select-expert-hidden").get(3).value,
                    "prjExperts.expert4": $(".select-expert-hidden").get(4).value
                },
                function(data) {
                }
            );
        });
    });
</script>
</head>
<body>
<div id="selectExpert" style="position: absolute; width: 500px; height: 116px; z-index: 1; background-color: gray">
    <p>单位：<select id="expertUnit"><option value="0">选择单位</option></select></p>
    <p>专家：<select id="expertName"><option value="0">选择专家</option></select></p>
    <p><input type="button" value="添加" id="ADD_BUTTON"/><input type="button" value="取消" id="CANCEL_BUTTON"/></p>
</div>
<table width="100%" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td width="20%" colspan="4">
        <div align="center">评审专家组成员</div>
        </td>
    </tr>
    <tr>
        <td width="20%" height="25">
        <div align="right">专家组长：</div>
        </td>
        <td width="30%"><input type="text" class="select-expert-text" readonly="true"/><input type="hidden" class="select-expert-hidden"/><input type="button" class="select-expert-button" value="选择" /></td>
        <td height="25" width="20%">
        <div align="right">专家1：</div>
        </td>
        <td width="30%"><input type="text" class="select-expert-text" readonly="true"/><input type="hidden" class="select-expert-hidden"/><input type="button" class="select-expert-button" value="选择" /></td>
    </tr>
    <tr>
        <td width="20%">
        <div align="right">专家2：</div>
        </td>
        <td width="30%"><input type="text" class="select-expert-text" readonly="true"/><input type="hidden" class="select-expert-hidden"/><input type="button" class="select-expert-button" value="选择" /></td>
        <td width="20%">
        <div align="right">专家3：</div>
        </td>
        <td width="30%"><input type="text" class="select-expert-text" readonly="true"/><input type="hidden" class="select-expert-hidden"/><input type="button" class="select-expert-button" value="选择" /></td>
    </tr>
    <tr>
        <td width="20%" height="25">
        <div align="right">专家4：</div>
        </td>
        <td width="30%"><input type="text" class="select-expert-text" readonly="true"/><input type="hidden" class="select-expert-hidden"/><input type="button" class="select-expert-button" value="选择" /></td>
        <td height="25" width="20%">&nbsp;</td>
        <td width="30%">&nbsp;</td>
    </tr>
</table>
<div>
    <input type="button" value="分配" id="ASSIGN_BUTTON"/>
</div>
</body>
</html>